var account_index_ops = {
    init: function () {
        this.eventBind();
    },
    eventBind: function () {
        $('.wrap_search .search').click(function () {
            var kw = $('.input-group input[name=mix_kw]').val();
            var st = $('.form-group select[name=status]').val();
            window.location.href = '/account/search/?kw=' + kw + '&st=' + st;
        });

        $('.remove').click(function () {
            var uid = $(this).attr('data-id');
            var callback = {
                'ok': function () {
                    $.ajax({
                        url: '/account/delete/',
                        type: 'POST',
                        dataType: 'json',
                        data: {
                            'uid': uid
                        },
                        success: function (data) {
                            if (data['code'] === 200) {
                                common_ops.alert('删除成功！');
                                window.location.href = '/account/index'
                            }
                            else {
                                common_ops.alert(data['msg']);
                            }
                        },
                        fail: function () {
                            common_ops.alert('操作失败，请重试！');
                        }
                    });
                },
                'cancel': function () {

                }
            };
            common_ops.confirm('确定删除该用户？', callback);
        });

        $('.reload').click(function () {
            var uid = $(this).attr('data-id');
            $.ajax({
                url: '/account/reload/',
                type: 'POST',
                dataType: 'json',
                data: {
                    'uid': uid
                },
                success: function (data) {
                    if (data['code'] === 200) {
                        common_ops.alert('恢复成功！');
                        window.location.href = '/account/index'
                    }
                    else {
                        common_ops.alert(data['msg']);
                    }
                },
                fail: function () {
                    common_ops.alert('操作失败，请重试！');
                }
            });
        });
    }
};

$(function () {
    account_index_ops.init();
});